package hotel.service.impl;

import org.springframework.stereotype.Component;

import hotel.entity.Price;
import hotel.service.IPriceService;

@Component
public class PriceServiceImpl<T> extends ServiceImpl<T> implements IPriceService<T> {

	@Override
	public double getPrice(int categoryid) {
		String hql="from Price p where p.category.categoryid = "+categoryid+" AND CURDATE() BETWEEN p.start_time AND p.end_time";
		Price price=(Price)dao.findFirstResult(hql);
		if(price==null||price.getPrice()<=0)
			return -1;
		return price.getPrice();
	}

}
